package com.winbomb.simulife.game.screens;

import com.winbomb.simulife.HonorType;
import com.winbomb.simulife.framework.Game;
import com.winbomb.simulife.framework.Screen;
import com.winbomb.simulife.framework.Input.TouchEvent;
import com.winbomb.simulife.game.Assets;
import com.winbomb.simulife.game.GameScreen;
import com.winbomb.simulife.game.TouchArea;

public class YPElectionScreen extends Screen {

	final TouchArea backArea = new TouchArea(20, 445, 75, 25);

	/** 竞选是否成功 */
	private boolean bSuccess;
	/** 竞选的类型 */
	private HonorType honorType;

	public YPElectionScreen(Game game, boolean bSucc, HonorType type) {
		super(game);

		this.bSuccess = bSucc;
		this.honorType = type;
	}

	public YPElectionScreen(Game game) {
		super(game);
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub

	}

	@Override
	public void present(float deltaTime) {
		g.drawPixmap(Assets.yp_apply, 0, 0);

		String tips = "";

		if (bSuccess) {
			if (honorType == HonorType.HN_YP_APPLY) {
				tips = "恭喜加入中国少先队!";
			} else if (honorType == HonorType.HN_YP_JUNIOR) {
				tips = "恭喜成为小队长！";
			} else if (honorType == HonorType.HN_YP_SECONDARY) {
				tips = "恭喜成为中队长！";
			} else if (honorType == HonorType.HN_YP_SENIOR) {
				tips = "恭喜成为大队长!";
			}
		} else {
			if (honorType == HonorType.HN_YP_APPLY) {
				tips = "抱歉，你没有加入中国少先队!";
			} else if (honorType == HonorType.HN_YP_JUNIOR) {
				tips = "抱歉，你没有成为小队长！";
			} else if (honorType == HonorType.HN_YP_SECONDARY) {
				tips = "抱歉，你没有成为中队长！";
			} else if (honorType == HonorType.HN_YP_SENIOR) {
				tips = "抱歉，你没有成为大队长!";
			}
		}

		g.drawText(tips, 100, 240);
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(float deltaTime) {
		updateTouchEvents();

		for (TouchEvent event : touchEvents) {
			if (event.type != TouchEvent.TOUCH_UP) {
				continue;
			}

			if (backArea.isBound(event)) {

				game.setScreen(new GameScreen(game));
			}
		}

	}

}
